package com.audaque.springboot.foshanupload.web.querydsldemo.dao;


import com.audaque.springboot.foshanupload.web.querydslmodedemo.model.entity.DemoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

import java.util.List;

/**
 * @author: zzx
 * @date: 2018/10/25 17:05
 * @description:
 */

public interface DemoMapper extends JpaRepository<DemoEntity, Integer>, JpaSpecificationExecutor<DemoEntity>, QuerydslPredicateExecutor<DemoEntity> {


    List<DemoEntity> findByAgeAndHeight(Integer age, Integer height);

    List<DemoEntity> findByNameLike(String name);

    @Query("from DemoEntity where name = ?1")
    List<DemoEntity> queryByNameUseHQL(String name);

    @Query(value = "select * from demo_entity where name=?", nativeQuery = true)
    List<DemoEntity> queryByNameUseSQL(String name);


    @Query(value = "update demo_entity set name=? where id=?", nativeQuery = true)
    @Modifying
    void updateUsersNameById(String name, Integer id);


}
